using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CocaCola_Inventory_System.Data_Access;

namespace CocaCola_Inventory_System.Forms
{
    public partial class EmailConfig : Form
    {
        public EmailConfig()
        {
            InitializeComponent();
        }

        private void EmailConfig_Load(object sender, EventArgs e)
        {
            textBox1.Text = Common.GetSystemEmail(((CocaCola_Inventory_System.Forms.Container)this.MdiParent).con);
            textBox2.Text = Common.GetSystemSMTP(((CocaCola_Inventory_System.Forms.Container)this.MdiParent).con);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (!Common.IsValidEmailAddress(textBox1.Text))
            {
                MessageBox.Show("Please Insert Valid Email Address");
                return;
            }
            if (Common.SetSystemEmail(((CocaCola_Inventory_System.Forms.Container)this.MdiParent).con,textBox1.Text) )
                MessageBox.Show("Email Changed Successfully");
            else
                MessageBox.Show("Failed To Change Email");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (Common.SetSystemSMTP(((CocaCola_Inventory_System.Forms.Container)this.MdiParent).con, textBox2.Text))
                MessageBox.Show("SMTP Changed Successfully");
            else
                MessageBox.Show("Failed To Change SMTP");
        }
    }
}